
*********************************
*	Author: Rithika Kumar	    *
*   Table A 18: Appendix        * 
*   Using survey experiment    *
*********************************

* Set working directory to "JOP replication files" folder on your computer

use "DATA FILES TO SHARE/survey_experiment_singleobs.dta", replace

* Encode because it is a string adn we cannot use it otherwise
encode panchayat, generate(panchayat_new)

* Create index on kowledge of ration card document knowledge 
gen know_ration_index = know_ration_doc_1 + know_ration_doc_2 + know_ration_doc_3 + know_ration_doc_4 + know_ration_doc_5 + know_ration_doc_6  +know_ration_doc_7 + know_ration_doc_8  +know_ration_doc_9 + know_ration_doc_98

* Create dummy for whether or not they identified the name of their CM correctly 
gen know_cm_correct = 0 
replace know_cm_correct = 1 if know_cm == 1


* Regression 

est clear

* 1. Naive regression 
quietly reghdfe know_ration_index mig_dummy 
eststo ration_m1
qui sum `e(depvar)' if e(sample)
estadd scalar Mean= r(mean)

* 2. Regression with controls 
quietly reghdfe know_ration_index mig_dummy age  i.religion pp_civic_jeevika i.household_inc edu1 edu2 edu3 edu4 edu5 agri_land_own_acre rel4 cc1 cc2 cc3 cc4 cc5 children_son children_daughter i.cook_sep joint_fam_correct , absorb(panchayat_new) vce(cluster panchayat_new)
eststo ration_controls
qui sum `e(depvar)' if e(sample)
estadd scalar Mean= r(mean)

* 3. CM name - niave regression 
quietly reghdfe know_cm_correct mig_dummy if know_cm<99
  eststo cm_m1 
  qui sum `e(depvar)' if e(sample)
estadd scalar Mean= r(mean)

* 4. CM - with controls 
quietly  reghdfe know_cm_correct mig_dummy age  i.religion pp_civic_jeevika i.household_inc edu1 edu2 edu3 edu4 edu5 agri_land_own_acre rel4 cc1 cc2 cc3 cc4 cc5 children_son children_daughter i.cook_sep joint_fam_correct if know_cm<99, absorb(panchayat_new) vce(cluster panchayat_new) 
eststo cm_controls
qui sum `e(depvar)' if e(sample)
estadd scalar Mean= r(mean)


** Export regressions 
esttab ration_m1 ration_controls cm_m1 cm_controls  using "OUTPUT/TABLES/Table_A18.tex", keep(mig_dummy) star(* 0.10 ** 0.05 *** 0.01) collabels(none) label stats(Mean r2 N, fmt(%9.2f %9.4f %9.0fc) labels("Dep. Var. Mean" "R-squared" "Observations")) plain b(a2) se(%9.2f) noobs noabbrev se nonumbers lines parentheses replace fragment 


estout ration_m1 ration_controls cm_m1 cm_controls ///
  using "OUTPUT/TABLES/Table_A18.tex", replace ///
  title("Procedural knowledge and skills are greater among women with migrant husbands") ///
    label  ///
    prehead("\begin{table}[H]" "\small" "\centering"  ///
            "\begin{tabular}{lcccc}" "\toprule" ///
            "& \multicolumn{2}{c}{\textit{No. of documents correctly identified}} & \multicolumn{2}{c}{\textit{Identify name of Chief Minister}}\\" ///
            "&(1)&(2) & (3) & (4)\\" "\hline" ) ///
    posthead("") keep(mig_dummy) varlabels(mig_dummy "Migrant Husband") ///
	stats(Mean r2 N, fmt(%9.2f %9.4f %9.0f) labels( "Dep. Var. Mean" "R2" "Observations")) cells(b(fmt(a2) star) se(par fmt(a2))) starlevels(* 0.10 ** 0.05 *** 0.01) style(tex) collabels(, none) mlabels(, none) ///
    prefoot("\midrule Controls& No & Yes & No & Yes\\"  "Village FE & No & Yes & No & Yes" " \midrule")   nonumber ///
     postfoot( "\bottomrule" "\end{tabular}" "\label{tab:know_test}" "\begin{tablenotes}" ///
             "\end{tablenotes}" "\end{table}")





